<?php
session_start();
/**
 * @author lebachvu
 * @copyright 2012
 */ 

 
include_once("Login.class.php");

$c_login = new Login();
?>

<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="content-type" content="text/html" />
	<meta name="author" content="lebachvu" />

	<title>Home Page</title>
</head>

<body>
<?php

if(isset($_POST["username"]) && isset($_POST["password"]))
{
    //Gan bien returnLogin cho class Login
    $c_login->returnLogin = $c_login->checkLogin($_POST["username"], $_POST["password"], $_POST["isSave"]);    
    
    //Gan bien viewLogin cho class Login
    $c_login->viewLogin = $c_login->ResultLogin();
    
    echo $c_login->viewLogin;    
}
else if(isset($_COOKIE["uName"]))
{
    $c_login->set_session("uName", $_COOKIE["uName"]);
    $c_login->set_session("uType", $_COOKIE["uType"]);
}

echo "<br/>User right is " . $_SESSION["uType"];

if(isset($_POST["Logout"])){
    $c_login->set_cookie("uName", "", time()-3600);
    $c_login->set_cookie("uType", "", time()-3600);
    header("Location: index.php");                       
}    
?>
<form name="DelCookie" action="Homepage.php" method="post">
    <input type="submit" name="Logout" value="[Log Out]" />
</form>
</body>
</html>